package com.nbgroup.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.nbgroup.pojo.ClueRecord;
import com.nbgroup.mapper.ClueRecordMapper;
import com.nbgroup.pojo.common.PageBean;
import com.nbgroup.service.IClueRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-10-28
 */
@Service
public class ClueRecordServiceImpl extends ServiceImpl<ClueRecordMapper, ClueRecord> implements IClueRecordService {


    /**
     * 线索记录查询
     * @param clueId
     * @return
     */
    @Override
    public PageBean PageQueryRecords(Long clueId) {
        List<ClueRecord> list = lambdaQuery().eq(ClueRecord::getClueId, clueId).orderBy(true, false, ClueRecord::getCreateTime).list();
        if (CollectionUtil.isEmpty(list)){
            list = List.of();
        }
        PageBean pageBean = PageBean.builder().code(200).rows(list).total(Long.parseLong(Integer.valueOf(list.size()).toString())).msg("查询成功").build();
        return pageBean;
    }
}
